﻿<%@ page title="申请提货" language="C#" masterpagefile="baseMasterPage.master" autoeventwireup="true" inherits="usertihuo_step2, App_Web_d_anrpev" %>
<%@ Register src="WebUserControl/LoginCard2.ascx" tagname="LoginCard" tagprefix="uc1" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
<style type="text/css">
#formtihuokacard table{margin:auto}

#formtihuokacard td{text-align:left;height:30px}
#address{width:450px}

#formtihuokacard div.cardnum{font-size:14px;font-weight:bold;padding:10px 0px 10px 0px;text-align:center}

</style>
<script type="text/javascript">
    window.onload = function() {
        $("#checktype").val("0");
    }

    function __cardloginchecker(evt) {
        if (jsformcheck(evt, "formCard"))
        {
            $ajax.load({url:"logincheckcard.aspx",data:"logincardnum="+$("#logincardnum").val()+"&logincardpassword="+$("#logincardpassword").val(),method:"post",type:"json"});
            //alert($ajax.responseJson.state);

            if ($ajax.responseJson.state == -100) {
                tipsShow("*该卡不存在或无效卡。"); 
            }
            else {
           
                if ($ajax.responseJson.state==0)
                {
                    tipsShow("*该卡未激活，不能进行提货申请。");
                }
                else if ($ajax.responseJson.state == 1) {
                    $("#updatemode").val(0);
                    __tihuo();
                }
                else if ($ajax.responseJson.state == 2) {
                    //允许修改提货信息
                    __showDetail("<br/><br/>*您已经成功申请提货，工作人员会及时安排发货。如需修改提货信息，请点击<a href=\"javascript:__modify();\" style=\"color:blue\">这里</a>");
                }
                else if ($ajax.responseJson.state == 3) {

                    $ajax.load({ url: "admin/xmlcard.aspx", data: "datatype=json&cardnum=" + $("#logincardnum").val(), method: "get", type: "json" });

                    var _html = "<br /><br /><fieldset class=\"fieldsetinfo\"><legend>快递信息</legend><p>快递公司:{express}</p><p>快递单号:{expressnum}</p><p>寄出时间:{expresstime}</p></fieldset>";
                    _html = _html.replace("{express}", unescape($ajax.responseJson[0].express));
                    _html = _html.replace("{expressnum}", unescape($ajax.responseJson[0].expressnum));
                    _html = _html.replace("{expresstime}", unescape($ajax.responseJson[0].expresstime).toString().formatToDate());

                    __showDetail(_html + "<br/><br/><br/>*您已经完成提货申请，工作人员已发货。");
                }
                else if ($ajax.responseJson.state == 4) {

                    $ajax.load({ url: "admin/xmlcard.aspx", data: "datatype=json&cardnum=" + $("#logincardnum").val(), method: "get", type: "json" });

                    var _html = "<br /><br /><fieldset class=\"fieldsetinfo\"><legend>快递信息</legend><p>快递公司:{express}</p><p>快递单号:{expressnum}</p><p>寄出时间:{expresstime}</p></fieldset>";
                    _html = _html.replace("{express}", unescape($ajax.responseJson[0].express));
                    _html = _html.replace("{expressnum}", unescape($ajax.responseJson[0].expressnum));
                    _html = _html.replace("{expresstime}", unescape($ajax.responseJson[0].expresstime).toString().formatToDate());
                    __showDetail(_html + "<br/><br/><br/>*工作人员已完成发货、客户收货确认。");
                }
            }
        }
        return false;
    }

    function __tihuo() {
        $form.reset("formtihuokacard");
        $('#dialog').dialog({
            autoOpen: true,
            width: 650,
            resizable: false,
            modal: true,
            title: "提货申请"
        });
    }

    
    function __showDetail(shtml)
    {
        $('#dialog2 .tips2').html(shtml);
        $form.ElementsDataFromXML("formtihuokacard", "admin/xmlcard.aspx?cardnum=" + $("#logincardnum").val());
        var t = "truename,phone,address,postcode".split(",");
        var i;
        for (i = 0; i < t.length; i++) {

            $("#" + t[i] + "_text").html($("#" + t[i]).val());
        }
        $("#sex_text").html($form.getRadioValue("sex"));
        
        $('#dialog2').dialog({
            autoOpen: true,
            width: 670,
            resizable: false,
            modal: true,
            title: "温馨提示"
        });
    }
    
    function __modify() {
        $("#updatemode").val(1);
        $('#dialog2').dialog("close");
        $('#dialog').dialog({
            autoOpen: true,
            width: 650,
            resizable: false,
            modal: true,
            title: "提货申请"
        });
    }
    
    

    function tihuo_action(evt) {
        var r = jsformcheck(evt, "formtihuokacard");
        if (!r) {
            return false;
        }
        
        var html="<p>姓名："+$("#truename").val()+"</p>";
        html+="<p>性别："+$form.getRadioValue("sex")+"</p>";
        html+="<p>联系电话："+$("#phone").val()+"</p>";
        html+="<p>寄送地址："+$("#address").val()+"</p>";
        html+="<p>邮编："+$("#postcode").val()+"</p>";
        $("#dialog3 .confirminfo").html(html);
        $('#dialog3').dialog({
            autoOpen: true,
            width: 650,
            resizable: false,
            modal: true,
            title: "温馨提示"
        });
        return false;
    }

    function tihuo_action_step2_cancel() {
        $('#dialog3').dialog("close");
    }
    
    function tihuo_action_step2()
    {
        $('#dialog3').dialog("close");
        $("#cardnum").val($("#logincardnum").val());
        
        var _data = "truename=" + $("#truename").val();
        _data += "&sex=" + $form.getRadioValue("sex");
        _data += "&phone=" + $("#phone").val();
        _data += "&address=" + $("#address").val();
        _data += "&postcode=" + $("#postcode").val();
        _data += "&cardnum=" + $("#cardnum").val();

        var _url;
        if ($("#updatemode").val().toString() == "1") {
            _url = "usertihuo_updateinfo_action.aspx";
        }
        else {
            _url = "usertihuo_action.aspx";
        }
        //alert(_url+"\n"+_data);
        $ajax.load({ url: _url, data: _data, method: "post", type: "json" });
        //alert($ajax.responseText);

        
        if ($("#updatemode").val().toString() == "1") {
            if ($ajax.responseJson.state == 1) {
                $('#dialog').dialog('close');
                tipsShow("*修改提货申请信息成功。");
            }
            else {
                $('#dialog').dialog('close');
                tipsShow("*修改提货申请信息失败。");
            }
        }
        else {
            if ($ajax.responseJson.state == 1) {
                $('#dialog').dialog('close');
                tipsShow("*提货申请成功。");
            }
            else {
                $('#dialog').dialog('close');
                tipsShow("*提货申请失败。");
            }
        }
    }


</script>

</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
    <div class="notebody">

        <div id="cardlogined" runat="server">


            <div class="UI_solo">
                <uc1:LoginCard ID="LoginCard21" runat="server" />
            </div>
            
            <div id="dialog" class="X-dialog">
                <br /><br />
                <form id="formtihuokacard" onsubmit="javascript:return tihuo_action(event);" method="post">
                    <table>
                        <tr>
                            <td class="fieldItem">姓名</td>
                            <td><input type="text" id="truename" name="truename" nullabled="false" maxlength="50" datatype="string" alerttext="姓名"/></td>
                        </tr>
                        <tr>
                            <td class="fieldItem">性别</td>
                            <td><input type="radio" name="sex" nullabled="false" alerttext="请选择性别" value="男"/>男<input type="radio" name="sex" value="女"/>女</td>
                        </tr>
                        <tr>
                            <td class="fieldItem">联系电话</td>
                            <td><input type="text" id="phone" name="phone" nullabled="false" maxlength="50" datatype="string" alerttext="联系电话"/></td>
                        </tr>
                        <tr>
                            <td class="fieldItem">收货地址</td>
                            <td><input type="text" id="address" name="address" nullabled="false" maxlength="255" datatype="string" alerttext="收货地址"/></td>
                        </tr>
                        <tr>
                            <td class="fieldItem">邮编</td>
                            <td><input type="text" id="postcode" name="postcode" nullabled="false" maxlength="50" datatype="string" alerttext="邮编"/></td>
                        </tr>
                        <tr>
                            <td></td>
                            <td>
                                <br />
                                <input id="cardnum" name="cardnum" type="hidden" value="" />
                                <input id="updatemode" name="updatemode" type="hidden" value="0" />
                                <input type="submit" value="提交" class="btn2" />
                            </td>
                        </tr>
                    </table>
                </form>
                <br /><br />
            </div>
            <div id="dialog2" class="X-dialog">
                <br /><br />
                <fieldset class="fieldsetinfo"><legend>您的提货信息</legend>
                    <p>姓名：<span id="truename_text"></span></p>
                    <p>性别：<span id="sex_text"></span></p>
                    <p>联系电话：<span id="phone_text"></span></p>
                    <p>寄送地址：<span id="address_text"></span></p>
                    <p>邮编：<span id="postcode_text"></span></p>
                </fieldset>
                 <div class="tips2"></div>
            </div>
            <div id="dialog3" class="X-dialog">
                <br /><br />
                <fieldset class="fieldsetinfo"><legend>您的提货信息如下</legend>
                    <div class="confirminfo"></div>
                </fieldset>
                <br /><br />
                <div class="center">
                    <input type="button" value="确认" onclick="javascript:tihuo_action_step2();" class="btn2" />
                    <input type="button" value="修改" onclick="javascript:tihuo_action_step2_cancel();" class="btn2" />
                </div>
                <br /><br />
            </div>
        </div>
    </div>
    
</asp:Content>

